package com.wc.算法基础课.E第五讲动态规划.状压DP.蒙德里安的梦想;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/27 19:30
 * @description https://www.acwing.com/problem/content/293/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 12, M = 1 << N;
    // f[i][j] 表示 i列状态为j，j中二进制数为1的就放横向的1 * 2的砖块，0就不放
    static long[][] f = new long[N][M];
    // st[i] 表示 i 状态是否满足 j | k,就相当于第i列与第i - 1列的状态是否能转移过来，就需要放竖着的块
    // (j & k) == 0, 就是k放了，j就不能放了,还有就是
    // j | k的 i列状态 是 j | k的状态连续0的个数不能为奇数，因为需要放竖着的块
    static boolean[] st = new boolean[M];
    static int n, m;

    public static void main(String[] args) {
        do {
            n = sc.nextInt();
            m = sc.nextInt();
            if (n == 0 || m == 0) break;
            // f会受到影响的
            for (int i = 0; i <= m; i++) {
                Arrays.fill(f[i], 0, 1 << n, 0);
            }
            // 初始化满足条件的转移列
            for (int i = 0; i < 1 << n; i++) {
                st[i] = true;
                // 表示连续0的个数
                int cnt = 0;
                for (int j = 0; j < n; j++) {
                    if ((i >> j & 1) == 1) {
                        if ((cnt & 1) == 1) st[i] = false;
                        cnt = 0;
                    } else cnt++;
                }
                if ((cnt & 1) == 1) st[i] = false;
            }
            // 0列什么都不用 表示1
            f[0][0] = 1;
            // 遍历每一列
            for (int i = 1; i <= m; i++) {
                for (int j = 0; j < 1 << n; j++) {
                    for (int k = 0; k < 1 << n; k++) {
                        if ((j & k) == 0 && st[j | k]) {
                            f[i][j] += f[i - 1][k];
                        }
                    }
                }
            }
            // 最终表示答案的是第m列不能再放1 * 2的横向的了，因为到达右面边界了
            out.println(f[m][0]);
        } while (true);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
